<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      py:with="modify_perm = 'WIKI_MODIFY' in perm(page.resource);
               admin_perm = 'WIKI_ADMIN' in perm(page.resource)">
  <xi:include href="layout.html" />
  <head>
    <title py:if="title">$title</title>
    <meta py:if="version or page.author == 'trac'" name="ROBOTS" content="NOINDEX, NOFOLLOW" />
    <link py:if="admin_perm or (not page.readonly and modify_perm)" rel="alternate" type="application/x-wiki"
          title="Edit this page" href="${href.wiki(page.name, action='edit')}" />
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#content").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
        $("#content").find(".wikianchor").each(function() {
          $(this).addAnchor(babel.format(_("Link to #%(id)s"), {id: $(this).attr('id')}));
        });
        $(".foldable").enableFolding(true, true);
      });
    </script>
  </head>

  <body>
    <div id="content" class="wiki">

      <py:if test="version">
        <br />
        <table id="info" summary="Revision info">
          <tbody>
            <tr><th scope="row" i18n:msg="version, author, date">
               Version $page.version (modified by ${authorinfo(page.author)}, ${dateinfo(page.time)} ago)
               (<a href="${href.wiki(page.name, action='diff', version=page.version)}">diff</a>)
            </th></tr>
            <tr><td class="message" xml:space="preserve">
              ${wiki_to_html(context, page.comment or '--')}
            </td></tr>
          </tbody>
        </table>
      </py:if>

      <div class="wikipage searchable" py:choose="" xml:space="preserve">
        <py:when test="page.exists">
          <?python
            last_modification = (page.comment and
                 _('Version %(version)s by %(author)s: %(comment)s',
                   version=page.version, author=format_author(page.author), comment=page.comment) or
                 _('Version %(version)s by %(author)s',
                   version=page.version, author=format_author(page.author)))
          ?>
          <div py:if="not version" class="trac-modifiedby" i18n:msg="reldate">
            <a href="${href.wiki(page.name, action='diff', version=page.version)}"
               title="$last_modification">Last modified</a> ${dateinfo(page.time)} ago
          </div>
          <div id="wikipage" py:content="wiki_to_html(context, text)" />
        </py:when>
        <py:otherwise>
          <p i18n:msg="name">The page ${name_of(page.resource)} does not exist. You can create it here.</p>
          <py:if test="higher">
            <p>You could also create the same page higher in the hierarchy:</p>
            <ul>
              <li py:for="markup in higher">${markup}</li>
            </ul>
          </py:if>
        </py:otherwise>
      </div>

      <xi:include href="list_of_attachments.html"
                  py:with="alist = attachments; compact = True; foldable = True"/>

      <py:with vars="delete_perm = 'WIKI_DELETE' in perm(page.resource);
                     rename_perm = 'WIKI_RENAME' in perm(page.resource)">
        <py:if test="admin_perm or (not page.readonly and (modify_perm or delete_perm))">
          <div class="buttons">
            <py:if test="modify_perm">
              <form method="get" action="${href.wiki(page.name)}" id="modifypage">
                <div>
                  <input type="hidden" name="action" value="edit" />
                  <py:choose>
                    <py:when test="page.exists">
                      <input type="submit" value="${_('Edit this page')}" accesskey="e" />
                    </py:when>
                    <py:otherwise>
                      <input type="submit" value="${_('Create this page')}" accesskey="e" />
                      <div py:if="templates" id="template">
                        <label for="template">Using the template:</label>
                        <select name="template">
                          <option selected="${not default_template in templates and 'selected' or None}"
                                  value="">(blank page)</option>
                          <option py:for="t in templates" value="$t"
                                  selected="${t == default_template or None}">$t</option>
                        </select>
                      </div>
                    </py:otherwise>
                  </py:choose>
                </div>
              </form>
              <py:if test="page.exists">
                <xi:include href="attach_file_form.html" py:with="alist = attachments"/>
              </py:if>
            </py:if>
            <form method="get" action="${href.wiki(page.name)}" id="rename" py:if="page.exists and rename_perm">
              <div>
                <input type="hidden" name="action" value="rename" />
                <input type="submit" value="${_('Rename page')}" />
              </div>
            </form>
            <py:if test="page.exists and delete_perm">
              <form method="get" action="${href.wiki(page.name)}">
                <div id="delete">
                  <input type="hidden" name="action" value="delete" />
                  <input type="hidden" name="version" value="$page.version" />
                  <py:if test="page.version == latest_version">
                    <input type="submit" name="delete_version" value="${_('Delete this version')}" />
                  </py:if>
                  <input type="submit" value="${_('Delete page')}" />
                </div>
              </form>
            </py:if>
          </div>
        </py:if>
      </py:with>

      <div class="wikipage searchable" py:if="not page.exists and related">
        <p>The following pages have a name similar to this page, and may be related:</p>
        <ul>
          <li py:for="markup in related">${markup}</li>
        </ul>
      </div>

    </div>
  </body>
</html>
